import pygame

class Player(pygame.sprite.Sprite):
    def __init__(self):
        self.offset = {}
        self.offset['x'] = 0
        self.offset['y'] = 0
        pygame.sprite.Sprite.__init__(self)

    def move(self, x, y):
        x = self.offset['x'] = self.offset['x'] + x
        y = self.offset['y'] = self.offset['y'] + y
        textureChangeX = textureChangeY = 0
        if x > 64:
            self.offset['x'] -= 64
        elif x < -64:
            self.offset['x'] += 64
        elif x == -64:
            self.offset['x'] = 0
            textureChangeX = -1
        elif x == 64:
            self.offset['x'] = 0
            textureChangeX = 1

        if y > 64:
            self.offset['y'] -= 64
        elif y < -64:
            self.offset['y'] += 64
        elif y == -64:
            self.offset['y'] = 0
            textureChangeY = -1
        elif y == 64:
            self.offset['y'] = 0
            textureChangeY = 1
            
        return (textureChangeX, textureChangeY)


    def getOffsets(self):
        return (self.offset['x'], self.offset['y'])
        
player = Player()